package com.wind.utils;

import android.content.Context;
import android.content.SharedPreferences;

import androidx.appcompat.app.AppCompatActivity;

import com.wind.beans.tokenBean;
import com.wind.soblogin.HttpManager;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class checkToken extends AppCompatActivity {

    public void getUserInfo(){
        HttpManager
                .getSobApi()
                .checkToken()
                .enqueue(new Callback<tokenBean>() {
                    @Override
                    public void onResponse(Call<tokenBean> call, Response<tokenBean> response) {
                        tokenBean token = response.body();
                        //将头像和id，以及他的个性签名记录下来
                        SharedPreferences sp = getSharedPreferences("userInfo", Context.MODE_PRIVATE);
                        SharedPreferences.Editor editor = sp.edit();
                        editor.putString("avatar", token.getData().getAvatar());
                        editor.putString("name", token.getData().getUserName());
                        editor.putString("sign", token.getData().getSign());
                        editor.commit();
                    }

                    @Override
                    public void onFailure(Call<tokenBean> call, Throwable t) {

                    }
                });
    }
}
